package com.lingz.manager.modules.wuxue.controller;

import com.lingz.manager.base.DevplatBaseController;
import com.lingz.manager.common.utils.ResultUtil;
import com.lingz.manager.common.vo.Result;
import com.lingz.manager.modules.wuxue.entity.KeyAreaInfo;
import com.lingz.manager.modules.wuxue.service.KeyAreaInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(description = "武穴重点区域管理接口")
@RequestMapping("/wuxue/keyarea")
@Transactional
public class KeyAreaInfoController extends DevplatBaseController<KeyAreaInfo,String> {
    @Autowired
    KeyAreaInfoService keyAreaInfoService;

    @Override
    public KeyAreaInfoService getService(){return keyAreaInfoService;}

    @GetMapping("/findKeyAreaInfoById")
    @ApiOperation("根据id获取区域信息")
    public Result<KeyAreaInfo> findKeyAreaInfoById(int id){
        return new ResultUtil<KeyAreaInfo>().setData(keyAreaInfoService.findKeyAreaInfoById(id));
    }

    @GetMapping("/findKeyAreaInfoByType")
    @ApiOperation("根据type获取区域信息")
    public Result<List<KeyAreaInfo>> findKeyAreaInfoByType(@RequestParam("type") String areaType){
        return new ResultUtil<List<KeyAreaInfo>>().setData(keyAreaInfoService.findKeyAreaInfoByType(areaType));
    }

    @GetMapping(value = "/findKeyAreaInfoList")
    @ApiOperation(value = "不分页查询区域信息")
    public Result<List<KeyAreaInfo>> findKeyAreaInfoList(KeyAreaInfo keyAreaInfo){
        return new ResultUtil<List<KeyAreaInfo>>().setData(keyAreaInfoService.findListKeyAreaInfo(keyAreaInfo));
    }
    @GetMapping(value = "/findKeyAreaInfoNum")
    @ApiOperation(value = "根据条件查询区域数量")
    public Result<Integer> findKeyAreaInfoNumList(@RequestParam("type") String areaType, @RequestParam(value = "city",required = false) String cityName,@RequestParam(value = "town",required = false) String townName,@RequestParam(value = "village",required = false) String villageName){
        return new ResultUtil<Integer>().setData(keyAreaInfoService.findKeyAreaInfoNum(areaType,cityName,townName,villageName));
    }
}
